package com.qianfeng.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.qianfeng.mapper.DeptMapper;
import com.qianfeng.pojo.Dept;

@Service
public class DeptServiceImpl implements DeptService {

	@Autowired
	private DeptMapper deptMapper;
	
	@Cacheable(value="myname") //这个作为键，下面return的数据作为值
	@Override
	public Dept findDept(String name) {
		System.out.println("从数据库中查询");//第一次会输出这句话，下一次就不会输出，因为下一次从缓存中查
		return deptMapper.findDeptByName(name);
	}

	@Override
	public void saeDept(Dept dept) {
		deptMapper.addDept(dept.getName());
		
	}

}
